package com.fpost.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class DateUtil {

	public static final String GMT = "GMT";
	public static final String SIMPLE_DATE_FORMAT = " dd-MMM-yyyy hh:mm:ss";
	public static final String COMPLEX_DATE_FORMAT = "EEE, d MMMMM yyyy HH:mm:ss";
	public static final String COMPLEX_DATE_FORMAT_TIME_ZONE = "EEE, d MMMMM yyyy HH:mm:ss zZ";
	
	public static Calendar getGMTCalendar() {
		return GregorianCalendar.getInstance(TimeZone.getTimeZone(DateUtil.GMT));
	}
	
	public static String dateToString(Date date, String dateFormat) {
		String srtDate = "";
		if (date != null) {
			DateFormat formatter = new SimpleDateFormat(dateFormat);
			srtDate = formatter.format(date);
		}		
		return srtDate;
	}

	public static Date stringToDate(String strDate, String dateFormat) {
		Date date = null;
		try {
			DateFormat formatter = new SimpleDateFormat(dateFormat);
			date = (Date) formatter.parse(strDate);

		} catch (ParseException e) {
			e.printStackTrace();
		}

		return date;
	}
}
